﻿<%@ Page Title="Title" Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Uber.Core.Model.Post>>"
    MasterPageFile="~/Views/Shared/Site.Master" %>

<asp:Content runat="server" ID="Title" ContentPlaceHolderID="TitleContent">
</asp:Content>
<asp:Content runat="server" ID="Main" ContentPlaceHolderID="MainContent">
    <div id="ask">
        <a href="<%=Url.Action("AskQuestion") %>">Ask Question</a>
    </div>
    <ul id="questions">
       <% Html.RenderPartial("rows",Model); %>       
    </ul>
    <%if((bool) ViewData["m"]) {%>
           <script type="text/javascript">
               $(function () {
                   fill({ m: true, o: "" }, { p: 1 });
               });

               function fill(r, sd) {
                   if (r == null) return;
                   $('#questions').append(r.o);
                   if (r.m) {
                       $('#questions').append(
            $('<li></li>').append($('<div class="more">more</div>').click(function () {
                sd.p++;
                var x = $(this);
                x.after('<span>Loading...</span>');
                x.hide();
                $.post('<%=Url.Action("Rows") %>', sd, function (da) { x.parent().remove(); fill(da, sd); });
            }))
            );
                   }
               }
    </script>
       <%}%>

</asp:Content>
